<?php


$id=$_GET["id"];
$groupid=$_GET["xid"];
$group_name=$_GET["x"];
$offset = $_GET["o"];
if($offset=="" || $offset==NULL)
{
	$offset=0;
}

//echo print_r($ids);


?>
<html>
  <head>
    <title>LinkStar - Fun way to share links</title>
  </head>
  <body>
	<div id="fb-root"></div>
	<div id="red"> </div>
	    <script>
		
		   alert("here");
			document.getElementById("red").innerHTML = "<img src='images/wait.gif' />";
			<?php

			if (isset($_REQUEST['ids']))
			{
				//that means these user ids got the invitations. so you can track these ids.
			  $ids = $_REQUEST['ids'];
				//echo print_r($ids);
				$con = mysql_connect("localhost", "vatsav", "2T*vzcd");
				if (!$con)
				{
				  echo('Could not connect: ' . mysql_error());
				}

				$db_selected = mysql_select_db("vatsav", $con);
					if (!$db_selected) {
						echo('Cant use db : ' . mysql_error());
				}


				for($i=0;$i<sizeof($ids);$i++)
				{
					$result = mysql_query("insert into invitations values(".$id.",".$ids[$i].",".$groupid.")");
						// Check result
						if (!$result) {
						   $message  = 'Invalid query: ' . mysql_error() . "<br/>";
						 //echo  $message;
					}
					
					$result = mysql_query("insert into invitations values(".$id.",".$ids[$i].",".$groupid.")");

					// Check result
					if (!$result) {
					   $message  = 'Invalid query: ' . mysql_error() . "<br/>";
					 //echo  $message;
					}
				}
				mysql_close($con);
			}
			?>
			//location.replace("http://studentweb.comminfo.rutgers.edu/2010-9-673-01/vatsav/index.php?p=groups");
			<?php header( 'Location: http://studentweb.comminfo.rutgers.edu/2010-9-673-01/vatsav/index.php?p=groups' ); ?>
		</script>
	
  </body>
</html>